package cn.hnh.config;

import org.omg.PortableInterceptor.Interceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author HuangNianHong
 * @Time 2020/12/12 17:30
 * 路由拦截 防止未登录访问个人页数据
 */

@Configuration
public class AdminRouteConfig implements WebMvcConfigurer {

    @Autowired
    @Qualifier("AdminRouteInterceptors")
    private HandlerInterceptor AdminRouteInterceptors;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        List<String> list = new ArrayList<>();
        list.add("/admin/css/**");
        list.add("/admin/images/**");
        list.add("/admin/js/**");
        list.add("/admin/plugins/**");
        registry.addInterceptor(AdminRouteInterceptors).addPathPatterns("/admin/**").excludePathPatterns(list);
    }
}
